package com.qk.mapper;

import com.qk.dto.ActivitiesDto;
import com.qk.entity.Activities;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ActivitiesMapper {

    List<Activities> selectList(ActivitiesDto activitiesDto);

    @Delete("delete from activity where id= #{id}")
    void delete(Integer id);

    @Insert("insert into activity(id, channel, name, start_time, end_time, description, type, discount, voucher, create_time, update_time) " +
            "values (#{id},#{channel},#{name},#{startTime},#{endTime},#{description},#{type},#{discount},#{voucher},#{createTime},#{updateTime})")
    void add(Activities activities);

    @Select("select id, channel, name, start_time, end_time, description, type, discount, voucher, create_time, update_time from activity where id= #{id}")
    Activities getById(Integer id);

    @Update("update activity set channel=#{channel},name=#{name},start_time=#{startTime},end_time=#{endTime},description=#{description},type=#{type},discount=#{discount},voucher=#{voucher},update_time=#{updateTime} where id= #{id}")
    void update(Activities activities);

    @Select("select id, channel, name, start_time, end_time, description, type, discount, voucher, create_time, update_time from activity where type= #{type}")
    List<Activities> getByType(Integer type);
}
